package com.kis.bot

import com.kis.bot.model.WeChat
import com.kis.bot.utils.api.Tools
import com.kis.bot.utils.api.getDomValue
import com.kis.bot.utils.api.getShortTime
import java.awt.Desktop
import java.awt.Toolkit
import java.io.File
import java.util.*

/**
 * Created by wanglong on 16-8-31.
 */

fun main(args: Array<String>) {
//    var f = File("${System.getProperty("user.dir")}/qr.jpeg")
//    Desktop.getDesktop().open(f)
//    Thread.sleep(10000000)
//    println(Tools.getUUID())
    var wx = WeChat()
    while (true) {
        Tools.createQrCode(wx)
        println("请扫描二维码")
        var code = ""
        code = Tools.checkLogin(wx, 1)
        if (code == "201") {
            println("请确认登录")
            code = Tools.checkLogin(wx, 0)
            if (code == "200") {
                println("登录成功")
                break
            }
        } else {

        }
    }
    if (!Tools.login(wx)) {
        println("登录获取信息失败")
    }
    println("正在初始化微信...")
    if (Tools.initWx(wx)) {
        println("初始化成功")
    } else {
        println("初始化失败")
    }
    println("欢迎你，${wx.user.get("NickName")}")
    if(Tools.webwxstatusnotify(wx)) print("提醒功能开启成功")
    println("正在导入联系人...")
    Tools.getContact(wx)
    println("正在导入群组...")
    Tools.getChat(wx)
    println(wx.chatroomList)
}

fun test() {
}